package com.zj.condition;


import org.springframework.context.annotation.Condition;
import org.springframework.context.annotation.ConditionContext;
import org.springframework.core.env.Environment;
import org.springframework.core.env.StandardEnvironment;
import org.springframework.core.type.AnnotatedTypeMetadata;
import org.springframework.util.StringUtils;

public class WindowsCondition implements Condition {
    @Override
    public boolean matches(ConditionContext context, AnnotatedTypeMetadata metadata) {
        Environment environment = context.getEnvironment();
        if(environment instanceof StandardEnvironment){
            StandardEnvironment env=(StandardEnvironment) environment;
        }
        String property = environment.getProperty("os.name");
        if(StringUtils.hasLength(property)&&property.toLowerCase().contains("windows")){
            return true;
        }

        return false;
    }
}
